/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.anniversary.service;

import me.zhengjie.modules.anniversary.domain.Department;
import me.zhengjie.modules.anniversary.service.dto.DepartmentDto;
import me.zhengjie.modules.anniversary.service.dto.DepartmentQueryCriteria;
import me.zhengjie.modules.anniversary.service.dto.MajorSmallDto;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;

/**
* @website https://el-admin.vip
* @description 服务接口
* @author Jiayin Wei
* @date 2020-07-22
**/
public interface DepartmentService {

    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<DepartmentDto>
    */
    List<DepartmentDto> queryAll(DepartmentQueryCriteria criteria, Boolean isQuery) throws Exception;

    /**
     * 根据ID查询
     * @param id ID
     * @return DepartmentDto
     */
    DepartmentDto findById(Long id);

    /**
    * 创建
    * @param resources /
    */
    void create(Department resources);

    /**
    * 编辑
    * @param resources /
    */
    void update(Department resources);

    /**
    * 删除
    * @param departmentDtos /
    */
    void delete(Set<DepartmentDto> departmentDtos);

    /**
     * 根据PID查询
     * @param pid /
     * @return /
     */
    List<Department> findByParentId(long pid);

    /**
     * 获取院系架构的可选年份
     * @param college
     * @return /
     */
    List<Integer> getDepartmentYears(String college);

    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<DepartmentDto> all, HttpServletResponse response) throws IOException;

    /**
     * 获取待删除的部门
     * @param departmentList /
     * @param departmentDtos /
     * @return /
     */
    Set<DepartmentDto> getDeleteDepts(List<Department> departmentList, Set<DepartmentDto> departmentDtos);

    /**
     * 根据ID获取同级与上级数据
     * @param deptDto /
     * @param departments /
     * @return /
     */
    List<DepartmentDto> getSuperior(DepartmentDto deptDto, List<Department> departments);

    /**
     * 根据年份获取专业
     *
     * @param year        /年份
     * @return /
     */
    List<MajorSmallDto> getMajors(Integer year);

    //根据名称与年份查询对应ID
    String getDeparmentID(String name, Integer year);

    /**
     * 根据学院现在的名称获取学院列表
     * @param name        /学院现在的名称
     * @return /
     */
    List<DepartmentDto> getCollegesByName(String name);

    /**
     * 根据年份获取学院列表
     * @param year        /年份
     * @return /
     */
    List<DepartmentDto> getCollegesByYear(String college, Integer year);

    /**
     * 根据入学年份与学院名称获取专业列表
     * @param year        /年份
     * @return /
     */
    List<Department> getMajorsList(Integer year, Integer nameId, Integer type);

    /**
     * 根据年份获取专业名称
     * @param year        /年份
     * @return /
     */
    List<String> getMajorsName(Integer year);

    /**
     * 构建树形数据
     * @param departmentDtos /
     * @return /
     */
    Object buildTree(List<DepartmentDto> departmentDtos);

    /**
     * 获取
     * @param deptId
     * @param deptList
     * @return
     */
    List<Long> getDeptChildren(Long deptId, List<Department> deptList);

    /**
     * 查询所有部门信息
     * @return
     */
    List<Department> findAll();
}
